﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MvcCms.Service.Models
{
    // Parameters sent to DataTables 
    public class DataTablesResponse
    {
        /// <summary>Total records, before filtering (i.e. the total number of records in the database)</summary>
        public int iTotalRecords { get; set; }
        /// <summary>Total records, after filtering (i.e. the total number of records after filtering has been applied - not just the number of records being returned in this result set)</summary>
        public int iTotalDisplayRecords { get; set; }
        /// <summary>An unaltered copy of sEcho sent from the client side. This parameter will change with each draw (it is basically a draw count) - so it is important that this is implemented. Note that it strongly recommended for security reasons that you 'cast' this parameter to an integer in order to prevent Cross Site Scripting (XSS) attacks.</summary>
        public int sEcho { get; set; }
        /// <summary>Optional - this is a string of column names, comma separated (used in combination with sName) which will allow DataTables to reorder data on the client-side if required for display</summary>
        public string sColumns { get; set; }
        /// <summary>The data in a 2D array</summary>
        public string[][] aaData { get; set; }
    }

    // Parameters received from DataTables 
    public class DataTablesRequest
    {
        /// <summary>Display start point</summary>
        public int iDisplayStart { get; set; }
        /// <summary>Number of records to display</summary>
        public int iDisplayLength { get; set; }
        /// <summary>Number of columns being displayed (useful for getting individual column search info)</summary>
        public int iColumns { get; set; }
        /// <summary>Extra Paramter, use to to call the same method to get different status's and so on.</summary>
        public string sExtraParam { get; set; }
        /// <summary>Global search field</summary>
        public string sSearch { get; set; }
        /// <summary>For almost all ajax use a dropdown should be placed on the grid to choose the column to search, 
        /// full column searching on the database doen's make good sense for many reasons.  It is great when all the data
        /// is on the client though.</summary>
        public string sSingleSearchField { get; set; }
        /// <summary>Global search is regex or not</summary>
        public bool bEscapeRegex { get; set; }
        /// <summary>Indicator for if a column is flagged as sortable or not on the client-side</summary>
        public List<bool> bSortable { get; set; }
        /// <summary>Indicator for if a column is flagged as searchable or not on the client-side</summary>
        public List<bool> bSearchable { get; set; }
        /// <summary>Individual column filter</summary>
        public List<string> sSearchColumns { get; set; }
        /// <summary>Individual column filter is regex or not</summary>
        public List<bool> bEscapeRegexColumns { get; set; }
        /// <summary>Number of columns to sort on</summary>
        public int iSortingCols { get; set; }
        /// <summary>Column being sorted on (you will need to decode this number for your database)</summary>
        public List<int> iSortCol { get; set; }
        /// <summary>Direction to be sorted - 'desc' or 'asc'. Note that the prefix for this variable is wrong in 1.5.x where iSortDir_(int) was used)</summary>
        public List<string> sSortDir { get; set; }
        /// <summary>Information for DataTables to use for rendering</summary>
        public int sEcho { get; set; }
        /// <summary>Calculated Page Number</summary>
        public int iCurrentPage { get; set; }

        public DataTablesRequest()
        {
            bSortable = new List<bool>();
            bSearchable = new List<bool>();
            sSearchColumns = new List<string>();
            iSortCol = new List<int>();
            sSortDir = new List<string>();
            bEscapeRegexColumns = new List<bool>();
        }
    }
}